<?php

	session_start();
  	require_once($CONF['root.dir']."application/view/modules/tabelClass.php");

function getindexpage(){
	global $CONF;	
    $page 		  	= LoadTpl($CONF['root.dir']."application/view/templates/main.html");
	$content  	  	= getContentBackend();
	$menu			= getMenu();
	$status			= getStatus();
    $this_Page 	  	= ParseTpl($page, array ("content" 		    => $content,
											 "menu"				=> $menu,
											 "status"			=> $status
										   ));
    print $this_Page;
}


function getLogin(){
	global $CONF,$conn;	
	$page 		  = LoadTpl($CONF['root.dir']."application/view/subModules/getFrmLogin.php");
	$Pages 	  	  = ParseVal($page, array ("content" 	=> $content
										   ));
	print $Pages;
}	

function getMenu(){
	if($_SESSION['AR_Priv']=="U"){
		$txt = '<ul>
				<li><a href="index.php">HOME</a></li>
				<li><a href="javascript:void(0)" >PROFILE</a>
					<ul>
					<li><a href="index.php?act=sejarah">Sejarah</a></li>  
					<li><a href="index.php?act=visimisi">Visi & Misi</a></li>                       
					<li><a href="index.php?act=alamat">Alamat</a></li>                       
					</ul>
				</li>
				<li><a href="javascript:void(0)">TES</a>
					<ul>
					<li><a href="index.php?act=stest">SOAL TES</a></li>
					<li><a href="index.php?act=upload">UPLOAD HASIL TES</a></li>
					<li><a href="index.php?act=htest">HASIL TES</a></li>
					</ul>
				</li>
				</ul>';	
	}else{
		$txt = ' <ul>
				<li><a href="index.php">HOME</a></li>
				<li><a href="javascript:void(0)" >PROFILE</a>
					<ul>
					<li><a href="index.php?act=sejarah">Sejarah</a></li>  
					<li><a href="index.php?act=visimisi">Visi & Misi</a></li>                       
					<li><a href="index.php?act=alamat">Alamat</a></li>                       
					</ul>
				</li>
				
				<li><a href="index.php?act=daftar">PENDAFTAR</a></li>
				
				<li><a href="javascript:void(0)">TES</a>
					<ul>
					<li><a href="index.php?act=stest">SOAL TES</a></li>
					<li><a href="index.php?act=upload">UPLOAD HASIL TES</a></li>
					<li><a href="index.php?act=htest">HASIL TES</a></li>
					</ul>
				</li>
				<li><a href="index.php?act=panitia">PANITIA</a></li>
				<li><a href="javascript:void(0)">LAPORAN</a>
					<ul>
					<li><a href="index.php?act=lapdaftar">Laporan Pendaftaran</a></li>  
					<li><a href="index.php?act=Laphtest">Laporan Hasil Tes</a></li>                
					</ul>
				</li>
				</ul>';
	}
	return $txt;
}

function getStatus(){
	$page = "Welcome ".$_SESSION["AR_userLogin"]." &nbsp;| <a href=\"javascript:void(0)\" onClick=\"return vLogout();\" class=\"logout\">Logout</a>";
	return $page;			
}
																																																			
function getContentBackend(){
	global $CONF,$conn;	
	$action = $_GET["act"];
	if($action=="sejarah"){
		$Pages = getSejarah();
	}elseif($action=="visimisi"){
		$Pages = getVisiMisi();
	}elseif($action=="alamat"){
		$Pages = getAlamat();
	}elseif($action=="daftar"){
		$Pages = getLamar();
	}elseif($action=="lapdaftar"){
		$Pages = getLapLamar();
	}elseif($action=="htest"){
		$Pages = getHasiltest();
	}elseif($action=="stest"){
		$Pages = getSoaltest();
	}elseif($action=="Laphtest"){
		$Pages = getLapTest();
	}elseif($action=="panitia"){
		$Pages = getpanitia();
	}elseif($action=="download"){
		$Pages = getDownload();
	}elseif($action=="upload"){
		$Pages = getupload();
	}else{
		$Pages = gethome();
	}
	return $Pages;
}

function getSejarah(){
	global $CONF,$conn;	
	$page 		  = LoadTpl($CONF['root.dir']."application/view/templates/boxFieldset.html");
	$content      = LoadTpl($CONF['root.dir']."application/view/templates/sejarah.html");
	$Pages 	  	  = ParseVal($page, array ("content" 	=> $content,
										   "title"      => "SEJARAH"));
	return $Pages;
}
function getVisiMisi(){
	global $CONF,$conn;	
	$page 		  = LoadTpl($CONF['root.dir']."application/view/templates/boxFieldset.html");
	$content      = LoadTpl($CONF['root.dir']."application/view/templates/visimisi.html");
	$Pages 	  	  = ParseVal($page, array ("content" 	=> $content,
										   "title"      => "Visi & Misi"));
	return $Pages;
}
function getAlamat(){
	global $CONF,$conn;	
	$page 		  = LoadTpl($CONF['root.dir']."application/view/application/view/templates/boxFieldset.html");
	$content      =  LoadTpl($CONF['root.dir']."application/view/templates/alamat.html");
	$Pages 	  	  = ParseVal($page, array ("content" 	=> $content,
										   "title"      => "Alamat"));
	return $Pages;
}

function getLamar(){
	global $CONF,$conn;	
	$page 		  = LoadTpl($CONF['root.dir']."application/view/application/view/templates/boxFieldset.html");
	$content      = require_once("application/view/modules/getLamar.php");
	$Pages 	  	  = ParseVal($page, array ("content" 	=> $content,
										   "title"      => "Data Pendaftaran"));
	return $Pages;
}

function getLapLamar(){
	global $CONF,$conn;	
	$page 		  = LoadTpl($CONF['root.dir']."application/view/application/view/templates/boxFieldset.html");
	$content      = require_once("application/view/modules/getLapLamar.php");
	$Pages 	  	  = ParseVal($page, array ("content" 	=> $content,
										   "title"      => "Data Laporan Pendaftaran"));
	return $Pages;
}

function getHasiltest(){
	global $CONF,$conn;	
	$page 		  = LoadTpl($CONF['root.dir']."application/view/application/view/templates/boxFieldset.html");
	$content      = require_once("application/view/modules/getHasilTes.php");
	$Pages 	  	  = ParseVal($page, array ("content" 	=> $content,
										   "title"      => "Data Hasil Test"));
	return $Pages;
}

function getLapTest(){
	global $CONF,$conn;	
	$page 		  = LoadTpl($CONF['root.dir']."application/view/application/view/templates/boxFieldset.html");
	$content      = require_once("application/view/modules/getLapHasilTes.php");
	$Pages 	  	  = ParseVal($page, array ("content" 	=> $content,
										   "title"      => "Data Laporan Hasil Test"));
	return $Pages;
}
function getpanitia(){
	global $CONF,$conn;	
	$page 		  = LoadTpl($CONF['root.dir']."application/view/application/view/templates/boxFieldset.html");
	$content      = require_once("application/view/modules/getPanitia.php");
	$Pages 	  	  = ParseVal($page, array ("content" 	=> $content,
										   "title"      => "Data Panitia"));
	return $Pages;
}
function gethome(){
	global $CONF,$conn;	
	$page 		  = LoadTpl($CONF['root.dir']."application/view/application/view/templates/boxFieldset.html");
	$content      =  LoadTpl($CONF['root.dir']."application/view/templates/home.html");
	$Pages 	  	  = ParseVal($page, array ("content" 	=> $content,
										   "title"      => "Home"));
	return $Pages;
}
function getSoaltest(){
	global $CONF,$conn;	
	$page 		  = LoadTpl($CONF['root.dir']."application/view/application/view/templates/boxFieldset.html");
	$content      =  LoadTpl($CONF['root.dir']."application/view/templates/downloadtes.html");
	$Pages 	  	  = ParseVal($page, array ("content" 	=> $content,
										   "title"      => "Soal Test"));
	return $Pages;
}
function getupload(){
	global $CONF,$conn;	
	$page 		  = LoadTpl($CONF['root.dir']."application/view/application/view/templates/boxFieldset.html");
	$content      =  LoadTpl($CONF['root.dir']."application/view/templates/upload.html");
	$Pages 	  	  = ParseVal($page, array ("content" 	=> $content,
										   "title"      => "Upload Jawaban Tes"));
	return $Pages;
}

function getDownload(){
	global $conn,$CONF;
		
		$file = $_GET["file"];
		$dir = $CONF['root.dir']."file/";
		if($file){
			$filename = $dir.$file;
		}else{
			$filename = $dir."SOAL_TEST.doc";
		}
		// set buat IE
		if(ini_get('zlib.output_compression'))
		ini_set('zlib.output_compression', 'Off');
		
		$file_extension = strtolower(substr(strrchr($filename,"."),1));
		
		if($filename!=""){
			switch($file_extension){
				case "pdf": $ctype="application/pdf"; break;
				case "exe": $ctype="application/octet-stream"; break;
				case "zip": $ctype="application/zip"; break;
				case "doc": $ctype="application/msword"; break;
				case "xls": $ctype="application/vnd.ms-excel"; break;
				case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
				case "gif": $ctype="image/gif"; break;
				case "png": $ctype="image/png"; break;
				case "jpeg":
				case "jpg": $ctype="image/jpg"; break;
				default: $ctype="application/force-download";
			}
			header("Pragma: public"); 
			header("Expires: 0");
			header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
			header("Cache-Control: private",false); 
			header("Content-Type: $ctype");
			header("Content-Disposition: attachment; filename=\"".basename($filename)."\";" );
			header("Content-Transfer-Encoding: binary");
			header("Content-Length: ".filesize($filename));
			readfile("$filename");
			exit();
		}else{
			echo "<html><title></title><body><center><h1>Error: You have not specified a file to download.</h1></body></html>";
			exit;	
		}
	
}


?>